package com.linefly.online_car;

import android.content.Intent;
import android.os.Build;
import android.os.Bundle;
import android.os.CountDownTimer;
import android.support.v7.app.AppCompatActivity;
import android.view.WindowManager;

import Util.NavigationBarUtil;
import Util.PreferenceUtil;

public class AD extends AppCompatActivity {
    private String token_str;//用户的token
    private CountDownTimer downTimer;//倒计时

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_ad);

        token_str = PreferenceUtil.getString("token","");

        if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT){
            getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
            //    getWindow().addFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_NAVIGATION);

        }
        if(NavigationBarUtil.hasNavigationBar(this)){
            NavigationBarUtil.initActivity(findViewById(android.R.id.content));//解决底部适配
        }

        //倒计时设置
        downTimer = new CountDownTimer(3 * 1000,1000) {
            @Override
            public void onTick(long l) {




            }

            @Override
            public void onFinish() {

                //实现页面跳转
                if(token_str.length()>0) {
                    startActivity(new Intent(AD.this, MainActivity.class));
                    finish();
                }else {
                    startActivity(new Intent(AD.this, LoginActivity.class));
                    finish();
                }




                downTimer.cancel();
            }
        };

        downTimer.start();

    }
}
